package servlet;


import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import flex01.SocketServer;

public class StartSocketServlet extends HttpServlet {
	public static ServletContext application;
	
	
	//public static int arr[] = {1991,1992,1993,1994,1995,1996,1997,1998,1999};
	public static ArrayList<SocketServer> socketServerList = new ArrayList<SocketServer>();
	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		for(SocketServer server:socketServerList)
			server.stopSocket();
		super.destroy(); 
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		
		application = this.getServletContext();
		System.out.println("init");
		for(int port = 1991; port <= 1991+30; port++){
			SocketServer server = new SocketServer(port);
			socketServerList.add(server);
			server.startSocket();
		}
	}

}
